% 准静态信道下的信道容量的计算
Eb_No_dB = [15];
Eb_No = 10.^(Eb_No_dB./10);
Tx = [1 2 4 8];
Rx = [1 2 4 8];
an = length(Tx);
N = 10000;
f = zeros(N,length(Eb_No_dB));
ff = zeros(N,length(Eb_No_dB));
x = zeros(N,length(Eb_No_dB));
for snr_count = 1:length(Eb_No_dB)
    for tt = 1:an
        tx = Tx(tt);
        rx = Rx(tt);
        for loop = 1:N
            H = (1/sqrt(2))*[randn(rx,tx) + j*randn(rx, tx)]; % rayleigh channel
            if tx > rx
                Q = H*H';
            else
                Q = H*H';
            end
            I = diag(ones(1,tx));
            capacity(loop) = log2(det(I + (Eb_No(snr_count)/tx)*Q))/tx;

        end
        [f x] = ecdf(capacity);

        ff = 1 - f;
        hold on;
        plot(x, ff, '-');
    end
    %

end

axis([0 4 0.9 1]);

xlabel('R(bit/s/Hz)');
ylabel('(C>R)probability');






